/**
 * @ author: 汪孟苹
 */
define(["jquery", "template",
	"scprit/followup/app/outPatient/outPatient.servers.js",
	"scprit/followup/template/outPatient/outPatient.tpl.js"],
	function ($, template, $outPatientServers, tpl) {
		var outPatientUi = {}

		var drawTaskBabycard = function (data) {
			return template("tpl_outPatient_taskBabycard", data)
		}
		var drawShowContainer = function (data) {
			return template("tpl_outPatient_showContainer", data)
		}
		var drawFollowUpTit = function (data) {
			return template("tpl_outPatient_followUpTit", data)
		}
		var drawFollowUp = function (data) {
			return template("tpl_outPatient_followUp", data)
		}
		var drawPrint = function (data) {
			return template("tpl_outPatient_print", data)
		}
		var drawPrintTem2 = function (data) {
			return template("tpl_outPatient_printTem2", data)
		}
		var drawPrintCreate = function (data) {
			return template("tpl_outPatient_printcreate", data)
		}
		var drawAnchorMenu = function (data) {
			return template("tpl_outPatient_anchorMenu", data)
		}
		var drawDischargeSummary = function (data) {
			return template("tpl_outPatient_dischargeSummary", data)
		}
		outPatientUi.taskBabycardInit = function (options) {
			$("#" + options.id).html(tpl.init())
			var h = drawTaskBabycard(options.list)
			$("#" + options.id).html(h)
		}
		outPatientUi.showContainerInit = function (options) {
			var data = {
				rows: $outPatientServers.handleTasks(options.list, options.taskId)
			}
			$("#" + options.id).html(tpl.init2())
			var h = drawShowContainer(data)
			$("#" + options.id).html(h)
		}
		outPatientUi.FollowUpTitInit = function (options) {
			var data = {
				queueName: options.queueName
			}
			$("#" + options.id).html(tpl.init3())
			var html = drawFollowUpTit(data)
			$("#" + options.id).html(html)
		}
		outPatientUi.followUpInit = function (options) {
			var data = $outPatientServers.handleFollowupTask(options)
			$("#" + options.id).html(tpl.followupInit())
			var html = drawFollowUp(data)
			$("#" + options.id).html(html)
		}
		outPatientUi.printInit = function (options) {
			var obj = $outPatientServers.handlePrintQuest(options.data)
			console.log('obj', obj)
			var data = {
				"info": $outPatientServers.handlePatientInfo(options.info),
				"rows": obj.questionsPrint,
				"task": $outPatientServers.handlePrintTask(options.data.task),
				"hospital": options.hospital,
				"followupGuidance": obj.followupGuidance,
			}
			//wxf 根据传入模版标识    确定调用不同的打印模版   1是病历本打印    2是纸质打印
			// 新增 3 是建档信息打印
			var html
			if (options.printTemState == "1") {
				$("#" + options.id).html(tpl.printInit())
				html = drawPrint(data)
			} else if (options.printTemState == "2") {
				$("#" + options.id).html(tpl.printTem2Init())
				html = drawPrintTem2(data)
			} else if (options.printTemState == '3') {
				$('#' + options.id).html(tpl.printCreate())
				html = drawPrintCreate(data)
			}

			$("#" + options.id).html(html)
		}
		outPatientUi.anchorMenuInit = function (options) {
			var data = {
				"list": $outPatientServers.handleAnchorMenu(options.list)
			}
			$("#" + options.id).html(tpl.anchorMenuInit())
			var html = drawAnchorMenu(data)
			$("#" + options.id).html(html)
		}
		outPatientUi.dischargeSummary = function (options) {
			options.dom.html(tpl.dischargeSummary())
			var html = drawDischargeSummary(options)
			options.dom.html(html)
		}
		return outPatientUi
	})